import type { TodosInfo } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace TodosApi {
  /** 待办事项接口参数 */
  export interface TodosParams extends TodosInfo {
    page?: number;
    pageSize?: number;
    // status?: string;
    // priority?: number;
    sortBy?: string;
    sortOrder?: string;
  }

  /** 登录接口返回值 */
  export interface TodosResult {
    current: number;
    pages: number;
    records: TodosInfo[];
    size: number;
    total: number;
  }
}

/**
 * 获取待办事项信息
 */
export async function getTodosInfoApi(data: TodosApi.TodosParams) {
  return requestClient.post<TodosApi.TodosResult>('/todos/info', data);
}

/**
 * 新增待办事项
 */
export async function addTodosInfoApi(data: TodosInfo) {
  return requestClient.post('/todos/add', data);
}

/**
 * 更新待办事项
 */
export async function updateTodosInfoApi(data: TodosInfo) {
  return requestClient.post('/todos/update', data);
}

/**
 * 删除待办事项
 */
export async function deleteTodosInfoApi(ids: number[] | undefined) {
  if (ids === undefined) return undefined;
  return requestClient.post('/todos/delete', ids);
}
